<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * 支付
 * fans（fans_wei@163.com）
 * 2016-06-05 上午10:11:09 
 **/
class Payment extends CI_Driver_Library {
	
	/**
	 * 支付列表
	 * Zewei Fan（fans_wei@163.com）
	 * 2015-09-29 
	 **/
	protected $valid_drivers 	= 
		array(
			'alipay', 'wxpay', 'calipay'
		);

	protected $_adapter				= 'alipay';
	protected $_order_id			= '';
	protected $_goods_name			= '';
	protected $_order_amount		= '';
	
	public function __construct($config = array())
	{
		//parent::__construct();
		if ( ! empty($config)){
			$this->_initialize($config);
		}
	}
	
	
	/**
	 * 配置参数
	 * fans（fans_wei@163.com）
	 * 2016-06-05 下午4:09:07
	 **/
	public function _initialize( $config )
	{
		if( count( $config) > 0 )
		{
			foreach( $config as $k => $v )
			{
				$this->{$k} = $v ;
			}
		}
	}
	
	
	/**
	 * 获取支付宝签名订单信息
	 * Zewei Fan
	 * 2016-08-22
	 **/
	public function getOrderSign()
	{
		$params = array(
			'order_id'	=> $this->_order_id ,
			'goods_name'	=> $this->_goods_name ,
			'order_amount'	=> $this->_order_amount ,		
		);

		return $this->{$this->_adapter}->getOrderSign( $params );
	}
	
	
	/**
	 * 用户去支付
	 * fans（fans_wei@163.com）
	 * 2016-06-05 下午4:07:23
	 **/
	public function topay()
	{
		$params = array(
			'order_id'	=> $this->_order_id ,
			'goods_name'	=> $this->_goods_name ,
			'order_amount'	=> $this->_order_amount ,		
		);
		return $this->{$this->_adapter}->topay( $params );
	}
	
	
	/**
	 * 支付异步校验
	 * fans（fans_wei@163.com）
	 * 2014-10-17 下午3:57:08
	 **/
	public function notify()
	{
		return $this->{$this->_adapter}->notify();
	}
	
	
	/**
	 * 支付同步校验
	 * fans（fans_wei@163.com）
	 * 2014-10-17 下午3:57:55
	 **/
	public function callback()
	{
		return $this->{$this->_adapter}->callback();
	}
	
	
	
	public function getOrder( $prepay_id ){
		
		return $this->{$this->_adapter}->getOrder( $prepay_id );
		
	}
	
}

/* End of file Cache.php */
/* Location: ./system/libraries/Connect.php */